package com.godpaper.as9.model
{
	import com.adobe.cairngorm.CairngormError;
	import com.adobe.cairngorm.CairngormMessageCodes;
	import com.adobe.cairngorm.model.IModelLocator;
	import com.godpaper.as9.control.upload.IUploadBase;
	import com.godpaper.as9.model.dataModel.SearchBehavior;
	import com.godpaper.as9.model.dataModel.SimpleUser;
	import com.godpaper.as9.vo.UserVO;
	
	import flash.net.SharedObject;
	import flash.net.URLVariables;
	
	import mx.collections.ArrayCollection;

	public class UserModelLocator implements IModelLocator,IUploadBase
	{
		// Singleton instance of ModelLocator
		private static var instance:UserModelLocator;
		
		[Bindable]public var status:Boolean=false;//False="Not Logged in.",True="Login Success";
		[Bindable]public var simpleUser:SimpleUser = new SimpleUser();
		[Bindable]public var step:int=0;
		[Bindable]public var stepAfterLogIn:int=0;
		[Bindable]public var userInfo:UserVO = new UserVO();
		[Bindable]public var userSO:SharedObject = SharedObject.getLocal("as9");
		[Bindable]public var userList:ArrayCollection = new ArrayCollection();
		[Bindable]public var searchBehavior:SearchBehavior = new SearchBehavior();
		
		public const STEP_SIGNUP:int = 0;
		public const STEP_LOGIN:int = 1;
		public const STEP_EXPLORER:int = 2;
		
		public function UserModelLocator(access:Private)
		{
			if (access != null){
				if (instance == null)
				{				
					instance = this;
				}
			}
			else{
				throw new CairngormError( CairngormMessageCodes.SINGLETON_EXCEPTION, "UserModelLocator" );
			}
		}
		/**
		 * 
		 * @return the Singleton instance of UserModelLocator
		 * 
		 */		
		public static function getInstance():UserModelLocator
		{
			if(instance == null)
			{
				instance = new UserModelLocator(new Private);
			}
			return instance;
		}
		
//--------------------------------------------------------------------------
//
//  Properties
//
//--------------------------------------------------------------------------		
        //----------------------------------
		//  urlVariables
		//----------------------------------
		private var _urlVariables:URLVariables = new URLVariables();
		public function set urlVariables(value:URLVariables):void
		{
			_urlVariables = value;
		}
		[Bindable]
		public function get urlVariables():URLVariables
		{
			return _urlVariables;
		} 
	}
}
/**
 * Inner class which restricts contructor access to Private
 */
class Private 
{
	
}